home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / hdf / unix / hdf3_2r2.lha / HDF3.2r2 / bkwdtest / rs3f.f < prev    next >
Encoding:
Text File  |  1992-10-29  |  6.9 KB  |  232 lines

  1.       program rs3f
  2. C
  3. C Program to read 3 SDSs from  bctest.hdf which contains an
  4. C SDS written by ws.c, an SDS written by wsf.f and one by wsf31.f.
  5. C It then print a table of the contents of each SDG for comparisons.
  6. C SDG/1 -- SDG/2 should have the same internal memory storage
  7. C sequence in terms of the data arrays; the dimension sizes
  8. C in C are reversed comparing with those in Fortran. 
  9. C In hdf file 3231hdf.dat, these two SDGs should have the same
  10. C sequences in terms of dimension sizes, dim scales, dim strings,
  11. C and data arrays.
  12. C Input file: bctest.hdf
  13.  
  14.  
  15.       integer dsgdata, dsgdims, dsgdisc, dsgdist, dsgrang
  16.       integer dspre32
  17.       integer ret, np, nr,nc, di(3)
  18.       integer id1(3),id2(3),id3(3), ispre32
  19.       integer rank,irank1,irank2,irank3
  20.       real    scpln(2), scrow(3), sccol(4), da(4,3,2)
  21.       real    maxi, mini
  22.       real    iscpln1(4), iscrow1(4), isccol1(4), ida1(4,3,2)
  23.       real    iscpln2(4), iscrow2(4), isccol2(4), ida2(4,3,2)
  24.       real    iscpln3(4), iscrow3(4), isccol3(4), ida3(4,3,2)
  25.       real    imaxi(3), imini(3)
  26.       integer i, j, k, no_err
  27.       character*7 l0(3), u0(3), fm0(3)
  28.       character*15 fn
  29. C      character*15 rslfn
  30.       character*12 il1(3),iu1(3), ifm1(3)
  31.       character*12 il2(3),iu2(3), ifm2(3)
  32.       character*12 il3(3),iu3(3), ifm3(3)
  33.  
  34.       di(1) = 4
  35.       di(2) = 3
  36.       di(3) = 2
  37.       np = 2
  38.       nr = 3
  39.       nc = 4
  40.       rank = 3
  41.       scpln(1) =   0.0
  42.       scpln(2) = 100.0
  43.       scrow(1) =   0.0
  44.       scrow(2) =  10.0
  45.       scrow(3) =  20.0
  46.       sccol(1) =   0.0
  47.       sccol(2) =   1.0
  48.       sccol(3) =   2.0
  49.       sccol(4) =   3.0
  50.       maxi = 123.0
  51.       mini = -1.0
  52.       l0(1) = 'Column'
  53.       u0(1) = 'Cm'
  54.       fm0(1) = 'Int32'
  55.       l0(2) = 'Line'
  56.       u0(2) = 'Inch'
  57.       fm0(2) = 'Int16'
  58.       l0(3) = 'Time'
  59.       u0(3) = 'Second'
  60.       fm0(3) = 'Int32'
  61.       fn = 'bctest.hdf'
  62. C      rslfn = 'rs3f.rsl'
  63.       no_err = 0
  64.  
  65.       do 200 i=1, np
  66.          do 180 j=1, nr
  67.             do 150 k=1, nc
  68.         da(k,j,i) = scpln(i) + scrow(j) + sccol(k)
  69. C             print *, da(k,j,i)
  70. 150        continue
  71. 180      continue
  72. 200   continue
  73.  
  74.           ret = dsgdims(fn, irank1, id1, 3)
  75.           no_err = no_err + ret
  76.           ispre32 = dspre32()
  77.           if (ispre32 .eq. 0) then
  78.               print *, 'SDG1 was written by HDF3.2'
  79.           else 
  80.               print *, '>>>>>>>>>>>>>>>>>>>>>>>>>'
  81.               print *, 'dspre32() returned wrong value for SDG1'
  82.               no_err = no_err-1
  83.           endif
  84.           do 250 i=1, rank
  85.               ret = dsgdist(i, il1(i), iu1(i), ifm1(i))
  86.               no_err = no_err + ret
  87. 250       continue
  88.           ret = dsgdisc(1, id1(1), isccol1)
  89.           no_err = no_err + ret
  90.           ret = dsgdisc(2, id1(2), iscrow1)
  91.           no_err = no_err + ret
  92.           ret = dsgdisc(3, id1(3), iscpln1)
  93.           no_err = no_err + ret
  94.           ret = dsgrang(imaxi(1), imini(1))
  95.           no_err = no_err + ret
  96.           ret = dsgdata(fn, irank1, id1, ida1)
  97.           no_err = no_err + ret
  98.  
  99.           ret = dsgdims(fn, irank2, id2, 3)
  100.           no_err = no_err + ret
  101.           ispre32 = dspre32()
  102.           if (ispre32 .eq. 0) then
  103.               print *, 'SDG2 was written by HDF3.2'
  104.           else
  105.               print *, '>>>>>>>>>>>>>>>>>>>>>>>>>'
  106.               print *, 'dspre32() returned wrong value for SDG2'
  107.               no_err = no_err-1
  108.           endif
  109.  
  110.           do 300 i=1, rank
  111.               ret = dsgdist(i, il2(i), iu2(i), ifm2(i))
  112.               no_err = no_err + ret
  113. 300       continue
  114.           ret = dsgdisc(1, id2(1), isccol2)
  115.           no_err = no_err + ret
  116.           ret = dsgdisc(2, id2(2), iscrow2)
  117.           no_err = no_err + ret
  118.           ret = dsgdisc(3, id2(3), iscpln2)
  119.           no_err = no_err + ret
  120.           ret = dsgrang(imaxi(2), imini(2))
  121.           no_err = no_err + ret
  122.           ret = dsgdata(fn, irank2, id2, ida2)
  123.           no_err = no_err + ret
  124.  
  125.           ret = dsgdims(fn, irank3, id3, 3)
  126.           no_err = no_err + ret
  127.           ispre32 = dspre32()
  128.           if (ispre32 .eq. 1) then
  129.               print *,'SDG3 was written by HDF prior to 3.2'
  130.           else
  131.               print *, '>>>>>>>>>>>>>>>>>>>>>>>>>'
  132.               print *, 'dspre32() returned wrong value for SDG3'
  133.               no_err = no_err-1
  134.           endif
  135.           do 350 i=1, rank
  136.               ret = dsgdist(i, il3(i), iu3(i), ifm3(i))
  137.               no_err = no_err + ret
  138. 350       continue
  139.           ret = dsgdisc(1, id3(1), isccol3)
  140.           no_err = no_err + ret
  141.           ret = dsgdisc(2, id3(2), iscrow3)
  142.           no_err = no_err + ret
  143.           ret = dsgdisc(3, id3(3), iscpln3)
  144.           no_err = no_err + ret
  145.           ret = dsgrang(imaxi(3), imini(3))
  146.           no_err = no_err + ret
  147.           ret = dsgdata(fn, irank3, id3, ida3)
  148.           no_err = no_err + ret
  149.  
  150. C Print results
  151. C
  152.  
  153. C      OPEN(UNIT=8, FILE=rslfn, STATUS='new')
  154. C      print *,'>>> rs3f:',abs(no_err),' calls failed >>>'
  155.       write(*, *)  '                     Print Results'
  156.       write(*, *) '        Origl  SDG/1  SDG/2  SDG/3  '
  157.       write (*, 560) rank, irank1,irank2,irank3
  158. 560   format (1x,4Hrank, 1x, 4I7)
  159.  
  160.       do 600 i=1,3
  161.           write (*,605) i, di(i),id1(i),id2(i), id3(i)
  162. 600   continue
  163. 605   format (1x,3Hdim,I1,2x,4(1x,I5,1x))
  164.  
  165.       do 610 i=1,4
  166.           write (*,612) i, sccol(i),isccol1(i),isccol2(i),
  167.      *            isccol3(i)
  168. 610   continue
  169. 612   format (5Hd1_sc,I1,1x,4(1x,F5.1,1x))
  170.  
  171.       do 615 i=1,3
  172.           write (*,618) i,scrow(i),iscrow1(i),iscrow2(i),
  173.      *        iscrow3(i)
  174. 615   continue
  175. 618   format (5Hd2_sc,I1,1x,4(1x,F5.1,1x))
  176.  
  177.       do 620 i=1,2
  178.           write (*,625) i,scpln(i),iscpln1(i),iscpln2(i),
  179.      *         iscpln3(i)
  180. 620   continue
  181. 625   format (5Hd3_sc,I1,1x,4(1x,F5.1,1x))
  182.  
  183.       write (*,631) maxi,imaxi(1),imaxi(2), 
  184.      *        imaxi(3)
  185. 631   format (4Hmaxi,3x,4(1x,F5.1,1x))
  186.  
  187.       write (*,635) mini,imini(1),imini(2),imini(3)
  188. 635   format (4Hmini,3x,4(1x,F5.1,1x))
  189.  
  190.       write (*,638)  l0(1),il1(1),il2(1),il3(1)
  191. 638   format (6Hlabel1,1x,4(A6,1x))
  192.       write (*,642)  l0(2),il1(2),il2(2),il3(2)
  193. 642   format (6Hlabel2,1x,A6,1x,2(A4,3x),1(A6,1x))
  194.       write (*,648)  l0(3),il1(3),il2(3),il3(3)
  195. 648   format (6Hlabel3,1x,A6,1x,2(A4,3x),1(A6,1x))
  196.  
  197.       write (*,650) u0(1),iu1(1),iu2(1),iu3(1)
  198. 650   format (1x, 5Hunit1,1x,A6,1x,2(A2,5x),1(A6,1x))
  199.       write (*,654) u0(2),iu1(2),iu2(2),iu3(2)
  200. 654   format (1x, 5Hunit2,1x,A6,1x,2(A4,3x),1(A6,1x))
  201.       write (*,658) u0(3),iu1(3),iu2(3),iu3(3)
  202. 658   format (1x, 5Hunit3,1x,4(A6,1x))
  203.  
  204.       do 660 i=1,3
  205.           write (*,665) fm0(i),ifm1(i),ifm2(i),ifm3(i)
  206. 660   continue
  207. 665   format (6Hformat,1x,A6,2(1x,A5,1x),1(1x,A6))
  208.  
  209.       write(*, *)  'Data:'
  210.       do 1000 i=1,np
  211.           do 900 j=1,nr
  212.               do 800 k=1,nc
  213.                  write (*, 1005) k,j,i, da(k,j,i),ida1(k,j,i),
  214.      *           ida2(k,j,i),ida3(k,j,i)
  215. 800           continue
  216. 900       continue
  217. 1000   continue
  218. 1005   format (3I2, 4(1x,F5.1,1x))
  219.  
  220.       print *,'>>> rs3f:',abs(no_err),' calls failed >>>'
  221.  
  222.       stop 
  223.       end
  224.  
  225.  
  226.      
  227.  
  228.  
  229.  
  230.